package com.easy.gao.mvptest.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.ComposeShader;
import android.graphics.LightingColorFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.Shader;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

import com.easy.gao.mvptest.R;

public class MyView extends View {
    Paint paint;
    Path path;

    public MyView(Context context) {
        super(context);
    }

    public MyView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        paint = new Paint();
        path = new Path();
        paint.setStyle(Paint.Style.FILL);
        paint.setColor(Color.parseColor("#ff0000"));
        paint.setAntiAlias(true);
    }

    public MyView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        //圆角矩形
        //canvas.drawRoundRect(100, 100, 500, 200, 50, 50, paint);
        //弧形和扇形
        // canvas.drawArc(200, 200, 800, 500, 0, 90, true, paint);
        //canvas.drawArc(200, 200, 800, 500, -180, 90, true, paint);
        //画笔画圆
//        path.addCircle(300, 300, 200, Path.Direction.CW);
//        path.addCircle(500, 300, 200, Path.Direction.CCW);
//        canvas.drawPath(path, paint);
//        paint.setColor(Color.BLACK);
//        paint.setStyle(Paint.Style.STROKE);
//        paint.setTextSize(40f);
//        path.moveTo(350, 750);
//        path.lineTo(600, 500);
//        path.lineTo(800, 500);
//        canvas.drawPath(path, paint);
//        canvas.drawText("练习", 700, 500, paint);
//        paint.setStyle(Paint.Style.FILL);
//        canvas.drawArc(100, 500, 600, 1000, 0, 85, true, paint);
//        paint.setColor(Color.parseColor("#00ff00"));
//        canvas.drawArc(100, 500, 600, 1000, 90, 85, true, paint);
//        paint.setColor(Color.parseColor("#0000ff"));
//        canvas.drawArc(100, 500, 600, 1000, 180, 85, true, paint);
//        paint.setColor(Color.parseColor("#ffff00"));
//        canvas.drawArc(100, 500, 600, 1000, 270, 85, true, paint);

//        Bitmap bitmap1 = BitmapFactory.decodeResource(getResources(), R.drawable.lxr_logo);
//        Shader shader1 = new BitmapShader(bitmap1, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
//
//        Bitmap bitmap2 = BitmapFactory.decodeResource(getResources(), R.drawable.pic_tx);
//        Shader shader2 = new BitmapShader(bitmap2, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
////
//        Shader shader=new ComposeShader(shader1,shader2, PorterDuff.Mode.SRC_OVER);
//        paint.setShader(shader1);
//        ColorFilter filter=new LightingColorFilter(0xffffff,0x000000);
//        paint.setColorFilter(filter);
//        canvas.drawCircle(500, 500, 400, paint);

    }
}
